package com.heima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.heima.dao.PermissionDao;
import com.heima.dao.RoleDao;
import com.heima.dao.UserDao;
import com.heima.pojo.Permission;
import com.heima.pojo.Role;
import com.heima.pojo.User;
import com.heima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashSet;
import java.util.Set;

@Service(interfaceClass = UserService.class)
@Transactional
public class UserServiceImpl  implements UserService {
    @Autowired
    private UserDao userDao;
    @Autowired
    private RoleDao roleDao;
    @Autowired
    private PermissionDao permissionDao;
    @Override
    public User findByUsername(String Username) {
 /*       User user = userDao.findByUsername(Username);
        Set<Role> roles = roleDao.findByUserId(user.getId());
        for (Role role : roles) {
           role.setPermissions(permissionDao.findByRoleId(role.getId()));
        }
        user.setRoles(roles);
        return user;*/
        User user = userDao.findByUsername(Username);
        return user;

    }
}